From: Xiaofeng Wang Date: Mon, 23 Mar 2026 08:55:56 +0000 (+0800) Subject: tests: Remove bcvk VM dispatch from Rust integration tests X-Git-Tag: archive/raspbian/2026.2-1+rpi1~1^2~10^2^2~5^2~2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=cf36d36de805203de476e1a388647ee86f2cd5c2;p=ostree.git tests: Remove bcvk VM dispatch from Rust integration tests VM deployment is now handled externally by `just test-tmt` (bcvk + tmt) or `just integration-container` (bcvk direct SSH). The Rust test binary runs inside the VM as root, so the require_root/RunMode dispatch logic is no longer needed. - Remove require_root(), RunMode enum, and bcvk dispatch code - Simplify booted_test! and privileged_test! macros to just register and run tests directly - Remove rustix dependency (no longer checking getuid) Co-Authored-By: Claude Opus 4.6 Signed-off-by: Xiaofeng Wang --- diff --git a/tests/bootc-integration/Cargo.lock b/tests/bootc-integration/Cargo.lock index 3dcd2048..5057910d 100644 --- a/tests/bootc-integration/Cargo.lock +++ b/tests/bootc-integration/Cargo.lock @@ -4,9 +4,9 @@ version = 4 [[package]] name = "anstream" -version = "0.6.21" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" dependencies = [ "anstyle", "anstyle-parse", @@ -19,15 +19,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" [[package]] name = "anstyle-parse" -version = "0.2.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" dependencies = [ "utf8parse", ] @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.60" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" +checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351" dependencies = [ "clap_builder", "clap_derive", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.60" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" dependencies = [ "anstream", "anstyle", @@ -115,9 +115,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.55" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" +checksum = "1110bd8a634a1ab8cb04345d8d878267d57c3cf1b38d91b71af6686408bbca6a" dependencies = [ "heck", "proc-macro2", @@ -127,15 +127,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" [[package]] name = "colorchoice" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" [[package]] name = "equivalent" @@ -231,9 +231,9 @@ checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "itoa" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "js-sys" @@ -253,15 +253,15 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "libc" -version = "0.2.182" +version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" [[package]] name = "libtest-mimic" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5297962ef19edda4ce33aaa484386e0a5b3d7f2f4e037cbeee00503ef6b29d33" +checksum = "14e6ba06f0ade6e504aff834d7c34298e5155c6baca353cc6a4aaff2f9fd7f33" dependencies = [ "anstream", "anstyle", @@ -327,9 +327,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.3" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "once_cell_polyfill" @@ -346,7 +346,6 @@ dependencies = [ "linkme", "paste", "quick-junit", - "rustix", "tempfile", "xshell", ] @@ -510,9 +509,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.26.0" +version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", "getrandom", diff --git a/tests/bootc-integration/Cargo.toml b/tests/bootc-integration/Cargo.toml index af3b21e1..3a2bf599 100644 --- a/tests/bootc-integration/Cargo.toml +++ b/tests/bootc-integration/Cargo.toml @@ -17,6 +17,5 @@ libtest-mimic = "0.8" linkme = "0.3" paste = "1" quick-junit = "0.5" -rustix = { version = "1", default-features = false, features = ["process"] } tempfile = "3" xshell = "0.2" diff --git a/tests/bootc-integration/src/tests/privileged.rs b/tests/bootc-integration/src/tests/privileged.rs index cfb87083..adc64563 100644 --- a/tests/bootc-integration/src/tests/privileged.rs +++ b/tests/bootc-integration/src/tests/privileged.rs @@ -2,32 +2,23 @@ //! //! Tests are split into two categories: //! -//! * **Booted** (`booted_test!`) — need a fully deployed ostree system -//! (composefs, sysroot, boot markers). When not root these dispatch via -//! `bcvk libvirt run` which does a full `bootc install to-disk`. +//! * **Booted** — need a fully deployed ostree system +//! (composefs, sysroot, boot markers). //! -//! * **Privileged** (`privileged_test!`) — just need root and the ostree -//! binary installed. When not root these dispatch via the much faster -//! `bcvk ephemeral run-ssh` (no disk install). +//! * **Privileged** — just need root and the ostree binary installed. +//! +//! VM deployment is handled externally by `just test-tmt` (bcvk + tmt) +//! or `just integration-container` (bcvk direct). These tests always +//! run as root inside the VM. use anyhow::{ensure, Result}; use xshell::{cmd, Shell}; use crate::integration_test; -/// How a test should be dispatched when not running as root. -/// See the module-level docs for details on each mode. -enum RunMode { - Booted, - Privileged, -} - macro_rules! booted_test { ($fn_name:ident, $body:expr) => { fn $fn_name() -> Result<()> { - if require_root(stringify!($fn_name), RunMode::Booted)?.is_some() { - return Ok(()); - } $body } integration_test!($fn_name); @@ -37,75 +28,12 @@ macro_rules! booted_test { macro_rules! privileged_test { ($fn_name:ident, $body:expr) => { fn $fn_name() -> Result<()> { - if require_root(stringify!($fn_name), RunMode::Privileged)?.is_some() { - return Ok(()); - } $body } integration_test!($fn_name); }; } -/// Returns `Ok(None)` if already root (test proceeds normally). -/// Otherwise dispatches to a VM per `mode` and returns `Ok(Some(()))`. -fn require_root(test_name: &str, mode: RunMode) -> Result> { - if rustix::process::getuid().is_root() { - return Ok(None); - } - - // We're on the host without root — delegate to a VM. - if std::env::var_os("OSTREE_IN_VM").is_some() { - anyhow::bail!("OSTREE_IN_VM is set but we're not root — VM setup is broken"); - } - - let image = std::env::var("OSTREE_TEST_IMAGE").map_err(|_| { - anyhow::anyhow!( - "not root and OSTREE_TEST_IMAGE not set; \ - run `just integration-container` to build and test" - ) - })?; - - let sh = Shell::new()?; - let bcvk = std::env::var("BCVK_PATH").unwrap_or_else(|_| "bcvk".into()); - - match mode { - RunMode::Booted => { - // Use a unique VM name per test to avoid collisions - let vm_name = format!("ostree-test-{}", test_name.replace('_', "-")); - - // Deploy a full VM (bootc install to-disk + boot) and wait for SSH - cmd!( - sh, - "{bcvk} libvirt run --name {vm_name} --replace --detach --ssh-wait {image}" - ) - .run()?; - - // Run the test inside the deployed VM - let result = cmd!( - sh, - "{bcvk} libvirt ssh {vm_name} -- ostree-bootc-integration-tests --exact {test_name}" - ) - .run(); - - // Always clean up the VM - let _ = cmd!(sh, "{bcvk} libvirt rm --stop --force {vm_name}").run(); - - // Propagate the test result - result?; - } - RunMode::Privileged => { - // Fast path: ephemeral container, no disk install needed - cmd!( - sh, - "{bcvk} ephemeral run-ssh {image} -- ostree-bootc-integration-tests --exact {test_name}" - ) - .run()?; - } - } - - Ok(Some(())) -} - booted_test!(privileged_verify_ostree_booted, { let sh = Shell::new()?;